package com.example.wechat.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import com.example.wechat.R;

public class SettingsFragment extends Fragment {
    private Switch darkModeSwitch;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_settings, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        // 初始化深色模式开关
        darkModeSwitch = view.findViewById(R.id.dark_mode_switch);
        darkModeSwitch.setChecked(AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES);
        darkModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
            AppCompatDelegate.setDefaultNightMode(isChecked ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
        });

        // 设置点击事件
        view.findViewById(R.id.security).setOnClickListener(v -> {
            Toast.makeText(getContext(), "账号安全", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.privacy).setOnClickListener(v -> {
            Toast.makeText(getContext(), "隐私设置", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.font_size).setOnClickListener(v -> {
            Toast.makeText(getContext(), "字体大小", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.language).setOnClickListener(v -> {
            Toast.makeText(getContext(), "语言设置", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.help).setOnClickListener(v -> {
            Toast.makeText(getContext(), "帮助中心", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.feedback).setOnClickListener(v -> {
            Toast.makeText(getContext(), "意见反馈", Toast.LENGTH_SHORT).show();
        });

        view.findViewById(R.id.about).setOnClickListener(v -> {
            Toast.makeText(getContext(), "关于微信", Toast.LENGTH_SHORT).show();
        });
    }
} 